﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OrganizeYourSearch.Helpers
{
    public static class TagHelper
    {

        private const int MaxFontSize = 20, MinFontSize = 12;

        /// <summary>
        /// Calucuates the relative size of our tagword to display in the TagCloud
        /// </summary>
        /// <param name="curFreq">No of occurances of the currently tagged tag word</param>
        /// <param name="maxFreq">No of occurances of the most tagged TagWord</param>
        /// <param name="minFreq">No of occurances of the least tagged TagWord</</param>
        /// <returns></returns>
        public static int CalculateSizeFactor(long curFreq, long maxFreq, long minFreq)
        {
            double multiplyFactor;
            if(maxFreq==minFreq)
                multiplyFactor=(MaxFontSize - MinFontSize) /1;
            else
                multiplyFactor= (MaxFontSize - MinFontSize) / (maxFreq - minFreq);

            int size = (int)(MinFontSize + (maxFreq - (maxFreq - (curFreq - minFreq))) * multiplyFactor);
            return size;
        }
    }
}
